//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

using System;

namespace Microsoft.Research.ScientificWorkflow.Helper
{
    /// <summary>
    /// This class is used to hold data for the different DAP
    /// types. This class contains arrays of arrays for storing
    /// data.
    /// </summary>
    class DataHolder
    {
        public DataHolder(int count, OpenDAPURI.DapVariableType dapType)
        {
            this.dapType = dapType;
            this.names = new string[count];
            this.dataArray = new object[count][];
        }

        public void AddData(int index, string name, object[] data)
        {
            this.names[index] = name;
            this.dataArray[index] = data;
        }

        public object[] GetData(int index)
        {
            if(index < 0 || index > this.dataArray.Length)
                throw new IndexOutOfRangeException("Index out of data bounds");

            return this.dataArray[index];
        }

        public int DataArrayCount
        {
            get { return this.dataArray.Length; }
        }

        private string[] names;
        private OpenDAPURI.DapVariableType dapType;
        private object[][] dataArray;
    }
}
